<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2024/9/19
  Time: 下午 07:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<script src="<%=request.getContextPath()%>/js/jquery-1.8.3.min.js"></script>
<body>
<div align="center">
  <h1>学生查询</h1>
  <table cellpadding="0" cellspacing="0" border="1" id="table">
    <tr>
      <td>序号</td>
      <td>名字</td>
      <td>年龄</td>
      <td>性别</td>
      <td>备注</td>
    </tr>

    <tr>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
    </tr>
  </table>

  <input type="button" id="btn" value="查询">
</div>
</body>

<script>
  $("#btn").click(function (){
    $.ajax({
        "url":"/StudentsServlet",
        "type":"post",
        "dataType":"json",
        "success":function (data){
          console.log(data)
          for (var i=0;i<data.length;i++){
            var $tr=("<tr><td>"+data[i].id+"</td><td>"+data[i].name+"</td><td>"+data[i].age+"</td><td>"+data[i].gender+"</td><td>"+data[i].major+"</td></tr>");
            $("#table") .append($tr);
          }
        }
    })
  })
</script>
</html>
